package isquirrel.beans;

public class Property {

	Long id;
	private String value;
	private String attribute;
	private int frequency;
	
	public Property() {
		this.frequency = 1;
	}
	
	public Property(String attribute, String value) {
		this.attribute = attribute;
		this.value = value;
		this.frequency = 1;
	}
	
	public Long getId() {
		return id;
	}

	@SuppressWarnings("unused")
	private void setId(Long id) {
		this.id = id;
	}

	
	public String getAttribute() {
		return attribute;
	}
	public void setAttribute(String attribute) {
		this.attribute = attribute;
	} 
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	public int getFrequency() {
		return frequency;
	}
	public void setFrequency(int frequency) {
		this.frequency = frequency;
	}
	
	@Override
	public boolean equals(Object other) {
		if (other instanceof Property) {
			return this.value.equals(((Property) other).getValue()) &&
			this.attribute.equals(((Property) other).getAttribute());
		}
		return false;
	}
	
	@Override
	public int hashCode() {
		return (String.valueOf(value.hashCode()) + String.valueOf(attribute.hashCode())).hashCode(); 
	}
	
	public int compareTo(Property p) {
		if (this.attribute.compareTo(p.attribute) != 0) {
			return this.attribute.compareTo(p.attribute);
		} else {
			return this.value.compareTo(p.value);
		}
	}
	
}
